﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace BenevolentSunData
{
    public class WallCell : Cell
    {
        public override string Name
        {
            get
            {
                return "";
            }
        }


        #region Graphics
        [ContentSerializerIgnore]
        public Model Model;

        [ContentSerializerIgnore]
        public Material Material = new Material();
        #endregion


        #region Initialization
        public WallCell()
        {
        }


        #region Graphics
        Matrix[] boneTransforms;
        #endregion


        #region Drawing
        public override void Draw(Vector3 position)
        {
            foreach (ModelMesh mesh in Model.Meshes)
            {
                Matrix world =
                    boneTransforms[mesh.ParentBone.Index] *
                    Matrix.CreateFromYawPitchRoll(Rotation, 0f, 0f) *
                    Matrix.CreateTranslation(position);
                Material.DrawMesh(mesh, world, Map.PointLights, Map.BeamLights);
            }
        }
        #endregion


        public override void LoadContent(ContentManager Content, Map map)
        {
            Material = map.Skin.GetMaterial("Wall");
            Model = Content.Load<Model>("Models/Wall");
            boneTransforms = new Matrix[Model.Bones.Count];
            Model.CopyAbsoluteBoneTransformsTo(boneTransforms);
            base.LoadContent(Content, map);
        }
        #endregion


        #region ICloneable
        public override object Clone()
        {
            WallCell cell = new WallCell();
            cell.Coords = new Point(Coords.X, Coords.Y);
            cell.Model = Model;
            cell.Material = Material.Clone();
            cell.boneTransforms = boneTransforms;
            cell.floorBoneTransforms = floorBoneTransforms;
            cell.floorModel = floorModel;
            cell.floorMaterial = floorMaterial.Clone();
            return cell;
        }
        #endregion

    }
}
